home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-06 | 3.5 KB | 129 lines | [TEXT/CWIE] |
- // Source for CBalloonApp class
-
-
- #include "CBalloonApp.h"
- #include "CHelpAttach.h"
-
- #include <LListIterator.h>
- #include <LWindow.h>
- #include <UDrawingState.h>
-
- // ===========================================================================
- // • CBalloonApp Class
- // ===========================================================================
-
- // ---------------------------------------------------------------------------
- // • CBalloonApp
- // ---------------------------------------------------------------------------
- // Constructor
-
- CBalloonApp::CBalloonApp()
- {
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~CBalloonApp
- // ---------------------------------------------------------------------------
- // Destructor
-
- CBalloonApp::~CBalloonApp()
- {
- }
-
- // Handle cursor motion for help balloons
- void CBalloonApp::AdjustCursor(const EventRecord &inMacEvent)
- {
- // Find out where the mouse is
- WindowPtr macWindowP;
- Point globalMouse = inMacEvent.where;
- Int16 thePart = ::FindWindow(globalMouse, &macWindowP);
-
- Boolean useArrow = true; // Assume cursor will be the Arrow
-
- if (macWindowP != nil) { // Mouse is inside a Window
-
- LWindow *theWindow = LWindow::FetchWindowObject(macWindowP);
- if ((theWindow != nil) &&
- theWindow->IsActive() &&
- theWindow->IsEnabled()) {
- // Mouse is inside an active and enabled
- // PowerPlant Window. Let the Window
- // adjust the cursor shape.
-
- // Get mouse location in Port coords
- Point portMouse = globalMouse;
- theWindow->GlobalToPortPoint(portMouse);
-
- theWindow->AdjustCursor(portMouse, inMacEvent);
- useArrow = false;
-
- // ----------------
- // Start of my bit
- // ----------------
- // Find the top pane under the mouse
- LPane* hitPane = GetPaneUnderMouse(theWindow, portMouse.h, portMouse.v);
-
- // Execute the CHelpAttach if the pane exists
- if (hitPane)
- hitPane->ExecuteAttachments(msg_ShowHelp, (void*) hitPane);
- // ----------------
- // End of my bit
- // ----------------
- }
- }
-
- if (useArrow) { // Window didn't set the cursor
- // Default cursor is the arrow
- SetCursor(&UQDGlobals::GetQDGlobals()->arrow);
- }
-
- // Rather than trying to calculate an accurate mouse region,
- // we define a region that contains just the one pixel where
- // the mouse is located. This is quick, and handles the common
- // case where this application is in the foreground but the user
- // isn't doing anything. However, any mouse movement will generate
- // a mouse-moved event.
-
- ::SetRectRgn(mMouseRgnH, globalMouse.h, globalMouse.v,
- globalMouse.h + 1, globalMouse.v + 1);
- }
-
- // Find the pane currently under the mouse
- LPane* CBalloonApp::GetPaneUnderMouse(
- LPane* inPane,
- Int32 inHorizPort,
- Int32 inVertPort)
- {
- #if 0
- LPane *hitSubPane = nil;
-
- // Does this pane provide a hit?
- if (!inPane->FindShallowSubPaneContaining(inHorizPort, inVertPort))
-
- // No hit => return this pane
- return inPane;
-
- // If there was a hit then we know that inPane is in fact a LView so
- // we can cast to get subpane list
-
- // Loop over all subpanes to find the first visible pane hit
- LListIterator iterator(((LView*) inPane)->GetSubPanes(), iterate_FromEnd);
- LPane *theSub;
-
- while (iterator.Previous(&theSub)) {
- if (theSub->Contains(inHorizPort, inVertPort) && theSub->IsVisible()) {
- hitSubPane = GetPaneUnderMouse(theSub, inHorizPort, inVertPort);
- if (hitSubPane == nil) {
- hitSubPane = theSub;
- }
- break;
- }
- }
-
- return hitSubPane;
- #else
- return inPane->FindDeepSubPaneContaining(inHorizPort, inVertPort);
- #endif
- }
-